package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.system.domain.FdStudent;
import com.ruoyi.system.service.IFdStudentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * FDController
 * 
 * @author ruoyi
 * @date 2021-07-22
 */
@RestController
@RequestMapping("/student")
public class FdStudentController extends BaseController
{
    @Autowired
    private IFdStudentService fdStudentService;

    /**
     * 查询FD列表
     */
    @PreAuthorize(hasPermi = "system:student:list")
    @GetMapping("/list")
    public TableDataInfo list(FdStudent fdStudent)
    {
        startPage();
        List<FdStudent> list = fdStudentService.selectFdStudentList(fdStudent);
        return getDataTable(list);
    }

    /**
     * 导出FD列表
     */
    @PreAuthorize(hasPermi = "system:student:export")
    @Log(title = "FD", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FdStudent fdStudent) throws IOException
    {
        List<FdStudent> list = fdStudentService.selectFdStudentList(fdStudent);
        ExcelUtil<FdStudent> util = new ExcelUtil<FdStudent>(FdStudent.class);
        util.exportExcel(response, list, "FD数据");
    }

    /**
     * 获取FD详细信息
     */
    @PreAuthorize(hasPermi = "system:student:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fdStudentService.selectFdStudentById(id));
    }

    /**
     * 新增FD
     */
    @PreAuthorize(hasPermi = "system:student:add")
    @Log(title = "FD", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FdStudent fdStudent)
    {
        return toAjax(fdStudentService.insertFdStudent(fdStudent));
    }

    /**
     * 修改FD
     */
    @PreAuthorize(hasPermi = "system:student:edit")
    @Log(title = "FD", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FdStudent fdStudent)
    {
        return toAjax(fdStudentService.updateFdStudent(fdStudent));
    }

    /**
     * 删除FD
     */
    @PreAuthorize(hasPermi = "system:student:remove")
    @Log(title = "FD", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fdStudentService.deleteFdStudentByIds(ids));
    }
}
